{echo:JS::import("form")}
{echo:JS::import('dialog?skin=tinysimple');}
{echo:JS::import('dialogtools');}
<link type="text/css" rel="stylesheet" href="{url:#css/ucenter.css}" />
<div class="container clearfix">
	{widget:name=sub_navs action=ucsidebar sidebar=$sidebar act=$actionId}
	<div class="content clearfix uc-content">
		<h1 class="title"><span>我的资助：</span></h1>
		{set:$uid=$user['id']}
		<div class="mt10">
		<table class="simple">
		<tr><td>账户余额</td><td>资助累计</td><td>已还累计</td><td>收益累计</td><td>待还累计</td></tr>
		<tr class="red">
		<td>{$currency_symbol}{$customer['balance']|'0'}</td>
		<td>{$currency_symbol}{echo:Zyk_tj::sum('pd','sq_money',"fc_id=$uid and is_ok>=2")|0}</td>
		<td>{$currency_symbol}{echo:Zyk_tj::sum('pd','h_money',"fc_id=$uid and is_ok=3")|0}</td>
		<td>{$currency_symbol}{echo:Zyk_tj::sum('pd','lx_money',"fc_id=$uid and is_ok=3")|0}</td>
		<td>{$currency_symbol}{echo:Zyk_tj::sum('pd','sq_money',"fc_id=$uid and is_ok=2")+Zyk_tj::sum('pd','lx_money',"fc_id=$uid and is_ok=2")}</td>
		</tr>
	</table>
	{if:!empty($pinfo['pd_id'])}
	<form id="sq_form" action="{url:/ucenter/help_add}" method="post" target="_blank" callback="submit_sq">
		<table class="form">
			<tr>
				<td >受助人：</td><input type="hidden" name="pid" id="pid" value="{$pinfo['pd_id']}">
				<td>{echo:Common::getUid($pinfo['sq_id'])['name']} ({echo:Zyk_tj::c_info($pinfo['sq_id'],'real_name')})</td>
			</tr>
			<tr>
				<td >担保人：</td>
				<td class="f12">{echo:Common::getUid($pinfo['dbr_id'])['name']} ({echo:Zyk_tj::c_info($pinfo['dbr_id'],'real_name')})</td>
			</tr>			<tr>
				<td >资助金额：</td>
				<td class="red">{$currency_symbol}{$pinfo['sq_money']}</td>  
			</tr>
			<tr>
				<td >资助收益：</td>
				<td class="red">{$currency_symbol}{$pinfo['lx_money']}</td>  
			</tr>			<tr>
				<td>二级密码：</td>
				<td><input type="password" name="pass2" id="pass2" pattern="required" style="width: 150px;" alt="输入二级密码"> <label></label></td>
			</tr>
			<tr>
				<td colspan="2" class="tc"><input type="submit" class="btn btn-main" value="提交"></td>
			</tr>
			
		</table>
	</form>
	{/if}
		</div>
		<div class="mt20 tab">
			<ul class="tab-head">
				<li>进行中<i></i></li>
				<li>已还款<i></i></li>
			</ul>
			<div class="tab-body">
			<!-- 进行中 -->
				<div>
					<table class="simple">
						<tr>
							<th width="40">资助金额</th><th width="40">应还金额</th><th width="50">受助人</th> <th width="50">担保人</th><th width="70">资助时间</th> <th width="30">期限</th><th width="80">到期日期</th><th width="80">剩余时间</th>
						</tr>
						{query:name=pd where=fc_id eq $user[id] and is_ok eq 2 order=pd_id desc page=1 id=$obj3}
						{set:$h_date=Zyk_tj::time($item['fc_time'],$item['qx']*30)}
						<tr class="{if:$key%2==1}odd{else:}even{/if} {if:$item['status']==2}noborder{/if}">
							 <td >{$currency_symbol}{$item['sq_money']}</td><td >{$currency_symbol}{$item['h_money']}</td><td>{echo:Common::getC($item['sq_id'])['real_name']}</td> <td >{echo:Common::getC($item['dbr_id'])['real_name']}</td><td>{$item['fc_time']}</td><td >{$item['qx']}个月</td><td>{$h_date}</td><td>{echo:Zyk_tj::ctime($item['fc_time'],$h_date,'d')}天</td>
						</tr>
						{/query}
					</table>
					<div class="page-nav">{echo:$obj3->pagebar(2)}</div>
				</div>
			<!-- 还款 -->
				<div>
					<table class="simple">
						<tr>
							<th width="90">资助时间</th><th width="40">资助金额</th><th width="40">收益</th><th width="50">实得金额</th> <th width="50">还款人</th><th width="90">还款时间</th>
						</tr>
						{query:name=pd where=fc_id eq $user[id] and is_ok eq 3 order=pd_id desc page=1 id=$obj4}
						<tr class="{if:$key%2==1}odd{else:}even{/if} {if:$item['status']==2}noborder{/if}">
							<td>{$item['fc_time']}</td> <td >{$currency_symbol}{$item['sq_money']}</td><td >{$currency_symbol}{$item['lx_money']}</td><td >{$currency_symbol}{$item['h_money']}</td><td>{echo:Common::getC($item['sq_id'])['real_name']}</td><td >{$item['h_time']}</td>
						</tr>
						{/query}
					</table>
					<div class="page-nav">{echo:$obj4->pagebar(3)}</div>
				</div>	
			</div>
		</div>
	</div>
</div>

<script>
	function submit_sq(e){
		if(!e){
			var pid = $("#pid").val();
			var pass2 = $("#pass2").val();
			$.get("{url:/ucenter/help_add}",{pid:pid,pass2:pass2},function(data){
				if(data['status']=='success'){
					art.dialog.tips("<p class='"+data['status']+"'>"+data['msg']+"</p>",2);
            		setTimeout("tools_reload()",2000);
					window.location.href = "{url:/ucenter/help_list/rand/}"+Math.random()+"#tab-0";
				}else{
					alert(data['msg']);
				}
			},'json');
		}
		return false;
	}

</script>
